package com.sunxu.main;

import com.sunxu.po.Role;
import com.sunxu.dao.RoleDao;
import com.sunxu.po.RoleParam;
import com.sunxu.utils.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;

/**
 * @author 孙许
 * @date 2018-07-10
 * @description
 */
public class Client {
    private static Logger logger = LogManager.getLogger(Client.class.getName());
    public static void main(String[] args) {
        SqlSession sqlSession = null;

        try {
            sqlSession = SqlSessionFactoryUtil.getSqlSessionFactory().openSession();
            RoleDao mapper = sqlSession.getMapper(RoleDao.class);
            RoleParam param = new RoleParam();
            param.setRoleName("n");
            param.setNote("te");
            List<Role> roleByParams = mapper.findRoleByParams(param);
            roleByParams.forEach(System.out::println);
        } finally {
            sqlSession.close();
        }
        logger.info("执行成功");
    }
}
